package com.cobo.fitness.web.calibreapi.routes;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cobo.fitness.web.calibreapi.entity.Book;
import lombok.Data;

@Data
public class SearchQuery {

    private String type;

    private String query;

    public void fillQuery(QueryWrapper<Book> wrapper) {
        switch (type) {
            case "all":
                break;
            case "author":
                wrapper.like("author", "%"+query+"%");
                break;
            case "name":
                wrapper.like("name", "%"+query+"%");
                break;
            case "bookLang":
                wrapper.eq("book_lang", query);
                break;
            case "series":
                wrapper.like("series", "%"+query+"%");
                break;
            case "bookFormat":
                wrapper.eq("book_format", query);
                break;
            case "bookPublish":
                wrapper.like("book_publish", "%"+query+"%");
                break;
            case "bookRate":
                wrapper.eq("book_rate", query);
                break;
            case "bookTag":
                wrapper.like("book_tag", "%"+query+"%");
                break;
            case "tagCode":
                wrapper.like("tag_code", "%"+query+"%");
                break;
        }
    }
}
